import request from '@/utils/request'
import requestFile from '@/utils/request-file'
import { formatDateByFmt } from '@/utils/util.js'

const prefixUrl = 'web/building'

// 查询地图中心点
export function get_map_center() {
  return request({
    url: prefixUrl + '/get_map_center',
    method: 'get'
  })
}

// 一键校准
export function aline_point_num() {
  return request({
    url: prefixUrl + '/aline_point_num',
    method: 'put'
  })
}

// 校准
export function aline_point_num_by_id(params) {
  return request({
    url: prefixUrl + '/aline_point_num_by_id',
    method: 'put',
    params
  })
}

// 获取省市区列表
export function pca_list_by_pid(params) {
  return request({
    url: prefixUrl + '/pca_list_by_pid',
    method: 'get',
    params
  })
}

// 获取区列表
export function area_list(params) {
  return request({
    url: prefixUrl + '/area_list',
    method: 'get',
    params
  })
}

// 获取区详情
export function area_search(params) {
  return request({
    url: prefixUrl + '/area_search',
    method: 'get',
    params
  })
}

// 获取所有省市列表
export function pc_list_all() {
  return request({
    url: prefixUrl + '/pc_list_all',
    method: 'get'
  })
}

// ip定位
export function ip_location() {
  return request({
    url: prefixUrl + '/ip_location',
    method: 'get'
  })
}

// 查询地址
export function search_address(params) {
  return request({
    url: prefixUrl + '/search_address',
    method: 'get',
    params
  })
}

// 分页查询地址
export function search_address_by_page(params) {
  return request({
    url: prefixUrl + '/search_address_by_page',
    method: 'get',
    params
  })
}

// 逆地址编码
export function geocoder(params) {
  return request({
    url: prefixUrl + '/geocoder',
    method: 'get',
    params
  })
}

// 新增
export function building_area_add(data) {
  return request({
    url: prefixUrl + '/building_area_add',
    method: 'post',
    data: data,
    content_type: 'json'
  })
}

// 编辑
export function building_area_edit(data) {
  return request({
    url: prefixUrl + '/building_area_edit',
    method: 'post',
    data: data,
    content_type: 'json'
  })
}

// 删除
export function building_area_del(params) {
  return request({
    url: prefixUrl + '/building_area_del',
    method: 'put',
    params
  })
}

// 列表
export function list(params) {
  return request({
    url: prefixUrl + '/list',
    method: 'get',
    params
  })
}

// 地图
export function list_for_map(params) {
  return request({
    url: prefixUrl + '/list_for_map',
    method: 'get',
    params
  })
}

// 详情
export function detail(params) {
  return request({
    url: prefixUrl + '/detail',
    method: 'get',
    params
  })
}

// 地区
export function selectSearchAreaVO(params) {
  return request({
    url: prefixUrl + '/selectSearchAreaVO',
    method: 'get',
    params
  })
}

// 媒体类型
export function get_media_types(params) {
  return request({
    url: prefixUrl + '/get_media_types',
    method: 'get',
    params
  })
}

// 获取点位类型，针对项目的分类特化
export function get_media_types_for_building_type(params) {
  return request({
    url: prefixUrl + '/get_media_types_for_building_type',
    method: 'get',
    params
  })
}

// 楼盘列表
export function list_all(params) {
  return request({
    url: prefixUrl + '/list-all',
    method: 'get',
    params
  })
}

// 楼盘列表
export function list_all_simple(params) {
  return request({
    url: prefixUrl + '/list-all-simple',
    method: 'get',
    params
  })
}

// 点位类型列表
export function list_media_types_not_include_gas_station(params) {
  return request({
    url: prefixUrl + '/list_media_types_not_include_gas_station',
    method: 'get',
    params
  })
}

// 楼层
export function list_floor_selections(params) {
  return request({
    url: prefixUrl + '/list_floor_selections',
    method: 'get',
    params
  })
}

// 获取加油站点位类型
export function list_media_types(params) {
  return request({
    url: prefixUrl + '/list_media_types',
    method: 'get',
    params
  })
}
// 获取点位类型(加油站)
export function list_media_types_of_gas_station(params) {
  return request({
    url: prefixUrl + '/list_media_types_of_gas_station',
    method: 'get',
    params
  })
}
// 获取楼盘详情
export function one(params) {
  return request({
    url: prefixUrl + '/one',
    method: 'get',
    params
  })
}

// 获取获取媒体类型id
export function get_media_type_id(params) {
  return request({
    url: prefixUrl + '/get_media_type_id',
    method: 'get',
    params
  })
}

// 项目id与点位类型关系信息
export function get_media_type_relation(params) {
  return request({
    url: prefixUrl + '/get_media_type_relation',
    method: 'get',
    params
  })
}

// 获取锁位导入模板
export function getBuildingImportExcel(params) {
  return requestFile({
    url: prefixUrl + '/getBuildingImportExcel',
    method: 'get',
    params,
    fileName: '选位导入楼盘模板' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.xlsx'
  })
}

// 地图导出空位表格
export function map_export_mp(data) {
  return request({
    url: prefixUrl + '/map_export_mp',
    method: 'post',
    data: data,
    content_type: 'json'
  })
}

// 导出上刊点位Excel
export function export_building_media_point_excel(data) {
  return requestFile({
    url: prefixUrl + '/export_building_media_point_excel',
    method: 'post',
    content_type: 'json',
    data,
    fileName: '上刊点位导出' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.zip'
  })
}

export function assign_worker(data) {
  return request({
    url: prefixUrl + '/assign_worker',
    method: 'post',
    content_type: 'json',
    data
  })
}
